﻿@{
    Layout = null;
}
@using LY.Manage.Model
<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>ShowRoleMenu</title>
    <!--引入文件-->
    <link href="~/Content/themes/default/easyui.css" rel="stylesheet" />
    <link href="~/Content/themes/icon.css" rel="stylesheet" />
    <script src="~/Scripts/jquery-1.8.2.min.js"></script>
    <script src="~/Scripts/jquery.easyui.min.js"></script>
    <script src="~/Scripts/easyui-lang-zh_CN.js"></script>
    <script src="~/Scripts/datapattern.js"></script>
    <script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>
    <script src="~/Scripts/jquery.validate.min.js"></script>
    <link href="~/Content/tableStyle.css" rel="stylesheet" />
   
    <script type="text/javascript">
        //获取url中的参数
        function getUrlParam(name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
            var r = window.location.search.substr(1).match(reg);  //匹配目标参数
            if (r != null) return unescape(r[2]); return null; //返回参数值
        }
        $(function () {
            console.log(getUrlParam("id"));
            $('#id').val(getUrlParam("id"));
        });

        function subForm() {
            //遍历树节点 获取选中的集合  1,2,3


            console.log("subForm--submit");
            $("#fmMain").submit();
        }
        function afterRoleMeunAdd(data) {
            console.log("sub-after-afterRoleMeunAdd:" + data);
            //调用父窗体中的方法
            window.parent.afterRoleMeunAdd(data);
        }

        $(function () {
            $('#tt').tree({
                checkbox: true,
                cascadeCheck: false,
                url: '/RoleInfo/GetUserTreeJson?roleIdzhi=' + getUrlParam("roleId"),
                
                onClick: function (node) {
                  //  alert(node.id);
                }
            }
            );
          

        });
    </script>

</head>
<body>

    <div>
        为用户 @{
            RoleInfo roleInfo = ViewBag.RoleInfo;
          
            @roleInfo.RoleName
        }分配角色


        @using (Ajax.BeginForm("AddRoleMenu", "RoleInfo", new { }, new AjaxOptions()
{
    HttpMethod = "post",
    OnSuccess = "afterRoleMeunAdd"
}, new { id = "fmMain" }))
        {
            @Html.AntiForgeryToken()
            @Html.ValidationSummary(true)

    <input type="hidden" id="roleId" name="roleId" value="@roleInfo.ID" />
            <input type="hidden" id="menulist" name="menulist" />


            <div class="easyui-panel" style="padding:5px">
                <ul id="tt" class="easyui-tree"></ul>
            </div>
        }
    </div>
    <script type="text/javascript">
        function getChecked() {
          
            var nodes = $('#tt').tree('getChecked');
         
            var s = '';
            for (var i = 0; i < nodes.length; i++) {
                if (s != '') s += ',';
                s += nodes[i].id;
            }
            //alert(s);
            $("#menulist").val(s);

        //   alert($("#menulist").val());
        }
    </script>
</body>
</html>
